package com.xyd.servlet;

import com.xyd.entity.News;
import com.xyd.service.NewsService;
import com.xyd.service.impl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 86186
 */
@WebServlet("/NewsShowServlet")
public class NewsShowServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String enId_str=request.getParameter("enId");
        long enId=Long.parseLong(enId_str);
        NewsService newsService=new NewsServiceImpl();

        News allNews=newsService.getAllNews(enId);

        request.setAttribute("allNews",allNews);
        request.getRequestDispatcher("manage/newsUpdate.jsp").forward(request,response);
    }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
